﻿@model XPressify.Models.RelationshipFamilyDeleteModel

@{
    ViewBag.Title = "Delete family relationship";
}


<script type="text/javascript">


    function checkAll() {
        var element = document.getElementsByName('DeleteBox');
        var i = 0;
        while (true) {
            var element = document.getElementsByName('AllFamilyUsers[' + i + '].IsSelected');
            if (element[0] == null) {
                break;
            }
            element[0].checked = true;
            i++;
        }
        var btn = document.getElementById("checkBtn")
        btn.onclick = uncheckAll;
        btn.value = "Uncheck all"
    }
    function uncheckAll() {
        var element = document.getElementsByName('DeleteBox');
        var i = 0;
        while (true) {
            var element = document.getElementsByName('AllFamilyUsers[' + i + '].IsSelected');
            if (element[0] == null) {
                break;
            }
            element[0].checked = false;
            i++;
        }
        var btn = document.getElementById("checkBtn")
        btn.onclick = checkAll;
        btn.value = "Check all"
    }
</script>


@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend style="font-size:x-large;color:#222">Relationships</legend>
        <div align="right"><input type="button" class="abtn" id="checkBtn" name="UnCheckAll" value="Check All" onclick="checkAll()" /></div>
        <table>
            <tr>
                <th width="50px">Name</th>
                <th></th>
                <th>Relationship</th>
                <th>Delete</th>
            </tr>
            @{  var index = 0;
                foreach (var family in Model.AllFamilyUsers)
                {
                    <tr>
                        <td>
                            <a href='@Url.Action("ProfileView", "Profile", new { id = family.Id })' class="nobtn">
                                <img src= "@family.ProfilePicturePath" alt="Profile picture" title="Profile picture" style="width: 50px;height: 50px;" />
                            </a>
                            
                        </td>
                        <td>
                            @Html.ActionLink(family.FullName, "ProfileView", "Profile", new { id = family.Id }, new {@class = "nobtn" })
                        </td>
                        <td>@family.RelationshipType</td>
                        <td>@Html.CheckBoxFor(model => model.AllFamilyUsers[index].IsSelected)</td>
                        @Html.HiddenFor(model => model.AllFamilyUsers[index].Id)
                        @Html.HiddenFor(model => model.AllFamilyUsers[index].RelationshipId)
                    </tr>
                    index++;
                }
            }
        </table>

    </fieldset>
}